<div class="modal fade" id="ModalCreateUser" role="dialog">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title"><?php echo __d('admin', 'New User'); ?></h4>
			</div>
			<div class="modal-body">
				<form id="UserNewForm">
					<div class="form-group">
						<label form="UserFirstName"><?php echo __d('admin', 'First Name'); ?></label>
						<input type="text" name="first_name" class="form-control" placeholder="<?php echo __d('admin', 'First Name'); ?>" />
					</div>
					<div class="form-group">
						<label form="UserLastName"><?php echo __d('admin', 'Last Name'); ?></label>
						<input type="text" name="last_name" class="form-control" placeholder="<?php echo __d('admin', 'Last Name'); ?>" />
					</div>
					<div class="form-group">
						<label form="UserUsername"><?php echo __d('admin', 'Username'); ?></label>
						<input type="text" name="username" class="form-control" placeholder="<?php echo __d('admin', 'Username'); ?>" />
					</div>
					<div class="form-group">
						<label for="UserEmail"><?php echo __d('admin', 'Email'); ?></label>
						<input type="email" name="email" class="form-control" placeholder="name@example.com" />
					</div>
					<div class="form-group">
						<input id="SubmitUserButton" type="button" value="<?php echo __d('admin', 'Create'); ?>" class="btn btn-primary" />
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script>
$( document ).ready(function() {
	$( "#SubmitUserButton" ).click(function(e) {
		$.ajax({
			url : "<?php echo $this->Html->url("/admin/users/create"); ?>",
			data : $("#UserNewForm").serialize(),
			method : 'POST',
			success : function(data, textStatus, xhr) {
				if( data.status === 1 ) {
					var User = data.result.User;
					var option = '<option value="' + User.id + '">' + User.name + '</option>';
					$( "#ProductUserId" ).append( option );
					$( "#ProductUserId" ).val( User.id ).focus();
					
				}
				$( '#ModalCreateUser' ).modal('hide');
			},
			dataType : "json"
		});
		e.preventDefault();
		return false;
	});
});
</script>